#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include "packetcapapi.h"

#include "pcaphost.h"
#include "pcap-ethnet.h"
#include "pcap-ipv4.h"
#include "pcap-ipv6.h"
#include "pcap-udp.h"
#include "pcapsendqueue.h"
#include "pcapsender.h"

int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);
    if (!initPCap()) {
        return 0;
    }

    qmlRegisterType<CPCapAddr>("PacketCap", 1, 0, "PCapAddr");
    qmlRegisterType<CPCapDev>("PacketCap", 1, 0, "PCapDev");
    qmlRegisterType<CPCapAuth>("PacketCap", 1, 0, "PCapAuth");
    qmlRegisterType<CPCapHost>("PacketCap", 1, 0, "PCapHost");
    qmlRegisterType<CPCapHandle>("PacketCap", 1, 0, "PCapHandle");
    qmlRegisterType<CPCapPktData>("PacketCap", 1, 0, "CPCapPktData");
    qmlRegisterType<CPCapPacket>("PacketCap", 1, 0, "PCapPacket");
    qmlRegisterType<CPCapEthFrame>("PacketCap", 1, 0, "PCapEthFrame");
    qmlRegisterType<CPCapEthLLCFrame>("PacketCap", 1, 0, "PCapEthLLCFrame");
    qmlRegisterType<CPCapEthSNAPFrame>("PacketCap", 1, 0, "PCapEthSNAPFrame");
    qmlRegisterType<CPCapIpv4Packet>("PacketCap", 1, 0, "PCapIpv4Packet");
    qmlRegisterType<CPCapIpv6Packet>("PacketCap", 1, 0, "PCapIpv6Packet");
    qmlRegisterType<CPCapUdpSegment>("PacketCap", 1, 0, "PCapUdpSegment");
    qmlRegisterType<CPCapSendQueue>("PacketCap", 1, 0, "PCapSendQueue");
    qmlRegisterType<CPCapSender>("PacketCap", 1, 0, "PCapSender");

    QQmlApplicationEngine engine;
    engine.addImportPath("qrc:/qml");
    engine.load(QUrl(QStringLiteral("qrc:/qml/main.qml")));
    return app.exec();
}
